<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>         <%-- JDBC程序包 --%>
<%@ page import="com.yootk.dbc.*" %>    <%-- 导入自定义程序包 --%>
<html>
<head>
    <title>JavaBean定义与使用</title>
</head>
<body>
<%
    String sql = "SELECT deptno,dname,loc FROM dept";
    PreparedStatement pstmt = DatabaseConnection.getConnection().prepareStatement(sql);
    ResultSet rs = pstmt.executeQuery();
%>
<table border="1" width="100%">
    <thead><tr><td>部门编号</td><td>部门名称</td><td>部门位置</td></tr></thead>
    <tbody>
    <%
        while (rs.next()) { // 迭代结果集
            long deptno = rs.getLong(1);
            String dname = rs.getString(2);
            String loc = rs.getString(3);
    %>
    <tr>
        <td><%=deptno%></td>
        <td><%=dname%></td>
        <td><%=loc%></td>
    </tr>
    <%
        }
        DatabaseConnection.close();
    %>
    </tbody>
</table>
</body>
</html>
